package gcj2008.round1a;


import java.util.Arrays;
import java.util.Comparator;

import common.AbstractRunner;
import common.AbstractRunner.SIZE;

public class A extends AbstractRunner {
	
	
	@Override
	public void handleCase(int caseNumber) throws Exception {		
		int n = scanner.nextInt();
		long []x = new long[n], y = new long[n];
		
		for (int i = 0; i < x.length; i++) {
			x[i] = scanner.nextInt();
		}
		
		for (int i = 0; i < y.length; i++) {
			y[i] = scanner.nextInt();
		}
		
		Arrays.sort(x);
		Arrays.sort(y);
		long res = 0;
		for (int i=0; i<n; i++) {
			res += x[i] * y[n-i-1];
		}
		out.write(Long.toString(res)+"\n");
	}
	
	public static void main(String[] args) throws Exception {
		new A().init(SIZE.small).execute();
	}
}
